namespace WorldMapBase.Tile.Pool
{
    public abstract class ClassObjectPool<T> : ObjectPool<T> where T : class,new()
    {
        public ClassObjectPool(int capacity) : 
            base(capacity,true,capacity/2,100,5f)
        {
#if UNITY_EDITOR
            _name = "ClassObjectPool: " + typeof(T).Name;
#endif
        }

        public ClassObjectPool(int capacity, bool enableAutoShrink, int idleMaxCount, int frameShrinkCount,float shrinkIntervalTime) : 
            base(capacity,enableAutoShrink,idleMaxCount,frameShrinkCount,shrinkIntervalTime)
        {
#if UNITY_EDITOR
            _name = "ClassObjectPool: " + typeof(T).Name;
#endif
        }
        
        protected override T ConstructItem()
        {
            return new T();
        }

        protected abstract void OnReset(T obj);

        protected override void BeforeRecover(T obj)
        {
            OnReset(obj);
        }

    }
}